home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / Schedule.cs625 < prev    next >
Text File  |  2008-02-22  |  10KB  |  237 lines

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Specialized;
  4. using System.Data.Common;
  5. using GBPVR.Public;
  6. using gbweb;
  7.  
  8. namespace GBPVRSchedule
  9. {
  10.     /// <summary>
  11.     /// Summary description for Schedule.
  12.     /// </summary>
  13.     public abstract class Schedule
  14.     {
  15.  
  16.         public abstract IList LoadRecordingSchedule();
  17.         public abstract IList GetListingsForTimePeriod(DateTime startTime, DateTime endTime);
  18.         public abstract Channel GetChannelByOID(int oid);
  19.         public abstract Programme GetProgrammeByOID(int oid);
  20.         public abstract ScheduledRecording GetScheduledRecordingByOID(int oid);
  21.         public abstract void CancelScheduledRecording(ScheduledRecording scheduledRecording);
  22.         public abstract void UpdateScheduledRecording(ScheduledRecording scheduledRecording);
  23.         public abstract void CreateReminder(Programme programme);
  24.         public abstract void RemoveReminder(Programme programme);
  25.         public abstract ArrayList GetReminderList();
  26.  
  27.         public enum DayType
  28.         {
  29.             SheduleThisDay = 0,
  30.             SheduleAnyDay = 1,
  31.             SheduleSpecificDays = 2
  32.         }
  33.  
  34.         public enum Quality
  35.         {
  36.             High = GBPVR.Public.ScheduledRecording.QUALITY_HIGH,
  37.             Medium = GBPVR.Public.ScheduledRecording.QUALITY_MEDIUM,
  38.             Low = GBPVR.Public.ScheduledRecording.QUALITY_LOW,
  39.             Custom1 = GBPVR.Public.ScheduledRecording.QUALITY_CUSTOM1,
  40.             Custom2 = GBPVR.Public.ScheduledRecording.QUALITY_CUSTOM2,
  41.             LiveTV = GBPVR.Public.ScheduledRecording.QUALITY_LIVETV
  42.         }
  43.  
  44.         public enum RecType
  45.         {
  46.             Daily = GBPVR.Public.ScheduledRecording.TYPE_RECORD_DAILY,
  47.             Once = GBPVR.Public.ScheduledRecording.TYPE_RECORD_ONCE,
  48.             Season = GBPVR.Public.ScheduledRecording.TYPE_RECORD_SEASON,
  49.             WeekDays = GBPVR.Public.ScheduledRecording.TYPE_RECORD_WEEK_DAYS,
  50.             WeekEnds = GBPVR.Public.ScheduledRecording.TYPE_RECORD_WEEKEND_DAYS,
  51.             Weekly = GBPVR.Public.ScheduledRecording.TYPE_RECORD_WEEKLY
  52.         }
  53.  
  54.  
  55.         public enum Status
  56.         {
  57.             Completed = GBPVR.Public.ScheduledRecording.STATUS_COMPLETED,
  58.             Completed_Error = GBPVR.Public.ScheduledRecording.STATUS_COMPLETED_WITH_ERROR,
  59.             Conflict = GBPVR.Public.ScheduledRecording.STATUS_CONFLICT,
  60.             Deleted = GBPVR.Public.ScheduledRecording.STATUS_DELETED,
  61.             InProgress = GBPVR.Public.ScheduledRecording.STATUS_IN_PROGRESS,
  62.             PlaceHolder = GBPVR.Public.ScheduledRecording.STATUS_PLACE_HOLDER,
  63.             Pending = GBPVR.Public.ScheduledRecording.STATUS_PENDING
  64.         }
  65.  
  66.         [Flags]
  67.         public enum Day
  68.         {
  69.             Sunday = GBPVR.Public.ReoccuringRecordingExtras.DAY_SUNDAY,
  70.             Monday = GBPVR.Public.ReoccuringRecordingExtras.DAY_MONDAY,
  71.             Tuesday = GBPVR.Public.ReoccuringRecordingExtras.DAY_TUESDAY,
  72.             Wednesday = GBPVR.Public.ReoccuringRecordingExtras.DAY_WEDNESDAY,
  73.             Thursday = GBPVR.Public.ReoccuringRecordingExtras.DAY_THURSDAY,
  74.             Friday = GBPVR.Public.ReoccuringRecordingExtras.DAY_FRIDAY,
  75.             Saturday = GBPVR.Public.ReoccuringRecordingExtras.DAY_SATURDAY
  76.         }
  77.  
  78.         public const int Keep_All_Recordings = GBPVR.Public.ReoccuringRecordingExtras.KEEP_ALL_FILES;
  79.  
  80.         public abstract bool ScheduleOnce(Programme programme, int PrePad, int PostPad);
  81.         public abstract bool ScheduleOnce(Programme programme, Quality quality, int PrePad, int PostPad);
  82.  
  83.         public abstract bool ScheduleAnyTime(Programme programme, RecType type, int PrePad, int PostPad);
  84.         public abstract bool ScheduleAnyTime(Programme programme, Quality quality, RecType type, int PrePad, int PostPad);
  85.         public abstract bool ScheduleAnyTime(Programme programme, Quality quality, DayType dayType, int keepnumRecordings, RecType type, int PrePad, int PostPad);
  86.         public abstract bool ScheduleAnyTime(Programme programme, Quality quality, DayType dayType, int keepnumRecordings, ArrayList days, RecType type, int PrePad, int PostPad);
  87.  
  88.         public abstract bool ScheduleThisTime(Programme programme, RecType type, int PrePad, int PostPad);
  89.         public abstract bool ScheduleThisTime(Programme programme, Quality quality, RecType rec, int PrePad, int PostPad);
  90.         public abstract bool ScheduleThisTime(Programme programme, Quality quality, DayType dayType, int keepnumRecordings, RecType type, int PrePad, int PostPad);
  91.         public abstract bool ScheduleThisTime(Programme programme, Quality quality, DayType dayType, int keepnumRecordings, ArrayList days, RecType type, int PrePad, int PostPad);
  92.  
  93.         public IDictionary LoadKnownRecordings()
  94.         {
  95.             // build up a list of the recording we already know about
  96.             IList scheduledRecordings = LoadRecordingSchedule();
  97.             IDictionary knownRecordings = new HybridDictionary();
  98.             foreach (ScheduledRecording scheduledRecording in scheduledRecordings)
  99.             {
  100.                 if (scheduledRecording.getRecordingStatus() == ScheduledRecording.STATUS_DELETED)
  101.                     continue;
  102.  
  103.                 if (scheduledRecording.getProgramme() != null)
  104.                 {
  105.                     knownRecordings[scheduledRecording.getProgramme().getOID()] = scheduledRecording;
  106.                 }
  107.             }
  108.             return knownRecordings;
  109.         }
  110.  
  111.         public int getSeasonDayMask(ScheduledRecording scheduledRecording)
  112.         {
  113.             int day_mask = -1;
  114.  
  115.             if ((RecType)scheduledRecording.getRecordingType() == RecType.Season)
  116.             {
  117.                 // create the database connection
  118.                 DbConnection aConnection = Global.GetOpenGBPVRDbConnection();
  119.  
  120.                 // create the command object and store the sql query
  121.                 DbCommand aCommand = aConnection.CreateCommand();
  122.  
  123.                 //Create the command sql query string
  124.                 aCommand.CommandText = "select day_mask from REOCCURING_EXTRAS where recording_group='" +
  125.                                        scheduledRecording.getRecordingGroup() + "'";
  126.                 aCommand.Connection = aConnection;
  127.  
  128.                 DbDataReader aReader = aCommand.ExecuteReader();
  129.                 if (aReader.Read())
  130.                 {
  131.                     day_mask = aReader.GetInt16(0);
  132.                 }
  133.  
  134.                 // close the reader
  135.                 aReader.Close();
  136.                 aConnection.Close();
  137.                 aConnection.Dispose();
  138.             }
  139.  
  140.             return day_mask;
  141.         }
  142.  
  143.         public string getSeasonDayString(ScheduledRecording scheduledRecording)
  144.         {
  145.             string days = string.Empty;
  146.  
  147.             if ((RecType)scheduledRecording.getRecordingType() == RecType.Season)
  148.             {
  149.                 int day_mask = getSeasonDayMask(scheduledRecording);
  150.  
  151.                 if (day_mask != -1)
  152.                 {
  153.                     if ((day_mask & ReoccuringRecordingExtras.DAY_MONDAY) > 0)
  154.                     {
  155.                         days = "Monday";
  156.                     }
  157.  
  158.                     if ((day_mask & ReoccuringRecordingExtras.DAY_TUESDAY) > 0)
  159.                     {
  160.                         if (days != string.Empty)
  161.                         {
  162.                             days += ", Tuesday";
  163.                         }
  164.                         else
  165.                         {
  166.                             days = "Tuesday";
  167.                         }
  168.                     }
  169.  
  170.                     if ((day_mask & ReoccuringRecordingExtras.DAY_WEDNESDAY) > 0)
  171.                     {
  172.                         if (days != string.Empty)
  173.                         {
  174.                             days += ", Wednesday";
  175.                         }
  176.                         else
  177.                         {
  178.                             days = "Wednesday";
  179.                         }
  180.                     }
  181.  
  182.                     if ((day_mask & ReoccuringRecordingExtras.DAY_THURSDAY) > 0)
  183.                     {
  184.                         if (days != string.Empty)
  185.                         {
  186.                             days += ", Thursday";
  187.                         }
  188.                         else
  189.                         {
  190.                             days = "Thursday";
  191.                         }
  192.                     }
  193.  
  194.                     if ((day_mask & ReoccuringRecordingExtras.DAY_FRIDAY) > 0)
  195.                     {
  196.                         if (days != string.Empty)
  197.                         {
  198.                             days += ", Friday";
  199.                         }
  200.                         else
  201.                         {
  202.                             days = "Friday";
  203.                         }
  204.                     }
  205.  
  206.                     if ((day_mask & ReoccuringRecordingExtras.DAY_SATURDAY) > 0)
  207.                     {
  208.                         if (days != string.Empty)
  209.                         {
  210.                             days += ", Saturday";
  211.                         }
  212.                         else
  213.                         {
  214.                             days = "Saturday";
  215.                         }
  216.                     }
  217.  
  218.                     if ((day_mask & ReoccuringRecordingExtras.DAY_SUNDAY) > 0)
  219.                     {
  220.                         if (days != string.Empty)
  221.                         {
  222.                             days += ", Sunday";
  223.                         }
  224.                         else
  225.                         {
  226.                             days = "Sunday";
  227.                         }
  228.                     }
  229.                 }
  230.             }
  231.  
  232.             return days;
  233.         }
  234.  
  235.     }
  236. }
  237.